<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>新增角色 简洁Bootstrap响应式后台管理系统模板下载</title>
    <meta name="keywords" content="Bootstrap模板,Bootstrap3模版,Bootstrap模板下载,Bootstrap后台模板,Bootstrap教程,Bootstrap中文,后台管理系统模板,后台模板下载,后台管理系统,后台管理模板">
    <meta name="description" content="JS代码网提供Bootstrap模板,后台管理系统模板,后台管理界面,Bootstrap后台板版下载">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/site.css" rel="stylesheet">
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <script src="js/jquery-3.6.0.js"/>
    <![endif]-->
</head>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
</script>
<body>
<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container-fluid">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <a class="brand" href="#">Admin</a>
            <div class="btn-group pull-right">
                <a class="btn" href="my-profile"><i class="icon-user"></i> Admin</a>
                <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                    <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="my-profile">个人资料</a></li>
                    <li class="divider"></li>
                    <li><a href="#">退出</a></li>
                </ul>
            </div>
            <div class="nav-collapse">
                <ul class="nav">
                    <li><a href="index">首页</a></li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">用户 <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="new-user">新建用户</a></li>
                            <li class="divider"></li>
                            <li><a href="users">管理用户</a></li>
                        </ul>
                    </li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">角色 <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><a href="new-role">新建角色</a></li>
                            <li class="divider"></li>
                            <li><a href="roles">管理角色</a></li>
                        </ul>
                    </li>
                    <li><a href="stats">救援</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3">
            <div class="well sidebar-nav">
                <ul class="nav nav-list">
                    <li class="nav-header"><i class="icon-map-marker"></i> 地图</li>
                    <li><a href="index">uwb界面</a></li>
                    <li><a href="stats">救援界面</a></li>
                    <li class="nav-header"><i class="icon-user"></i> 管理</li>
                    <li><a href="users">用户</a></li>
                    <li><a href="roles">角色</a></li>
                    <li class="nav-header"><i class="icon-wrench"></i> 设置</li>
                    <li><a href="my-profile">我的资料</a></li>
                    <li class="active"><a href="setting">串口设置</a></li>
                    <li><a href="#">退出</a></li>
                </ul>
            </div>
        </div>
        <div class="span9">
            <div class="row-fluid">
                <div class="page-header">
                    <h1>串口设置 <small>port setting</small></h1>
                </div>
                <form class="form-horizontal">
                    <fieldset>
                        <div  class="span6" style="height: 20px">

                            <div class="control-group">
                                <label class="control-label">可用串口</label>
                                <div class="controls">
                                    <div class="dropdown">
                                        <select style="width: 100px" class="selectpicker " id="port">
                                            <option th:each="item:${ports}"
                                                    th:value="${item}"
                                                    th:text="${item}"
                                                    th:selected="${port==item}">
                                            </option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">波特率</label>
                                <div class="controls">
                                    <div class="dropdown">
                                        <select style="width: 100px" class="selectpicker " id="botelv">
                                        <option value="1200" th:selected="${botelv==1200}">1200</option>
                                        <option value="2400" th:selected="${botelv==2400}">2400</option>
                                        <option value="9600" th:selected="${botelv==9600}">9600</option>
                                        <option value="14400" th:selected="${botelv==14400}">14400</option>
                                        <option value="19200" th:selected="${botelv==19200}">19200</option>
                                        <option value="57600" th:selected="${botelv==57600}">57600</option>
                                        <option value="115200" th:selected="${botelv==115200}">115200</option>
                                    </select>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">校验位</label>
                                <div class="controls">
                                    <div class="dropdown">
                                        <select style="width: 100px" class="selectpicker " id="jiaoyanwei">
                                            <option value=0 th:selected="${jiaoyanwei==0}">无校验</option>
                                            <option value=1 th:selected="${jiaoyanwei==1}">奇校验</option>
                                            <option value=2 th:selected="${jiaoyanwei==2}">偶校验</option>
                                            <option value=3 th:selected="${jiaoyanwei==3}">1校验</option>
                                            <option value=4 th:selected="${jiaoyanwei==4}">0校验</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">停止位</label>
                                <div class="controls">
                                    <div class="dropdown">
                                        <select style="width: 100px" class="selectpicker " id="tingzhiwei">
                                            <option value=1 th:selected="${tingzhiwei==1}">1位</option>
                                            <option value=3 th:selected="${tingzhiwei==3}">1.5位</option>
                                            <option value=1 th:selected="${tingzhiwei==2}">2位</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">数据传输格式</label>
                                <div class="controls">
                                    <div class="dropdown">
                                        <select style="width: 100px" class="selectpicker " id="type">
                                            <option value=0 th:selected="${type==0}">Ascii</option>
                                            <option value=1 th:selected="${type==1}">Hex</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="controls">
                                    <div class="dropdown">
                                        <input onclick="OpenSerial()" th:class="${isopen?'btn btn-primary':'btn btn-danger'}"  type="button" th:value="${isopen?'关闭串口':'打开串口'}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="span6" style="height: 20px">
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <textarea style="height: 100px" type="text" class="form-control" placeholder="Search for..."></textarea>
                                </div><!-- /input-group -->
                            </div><!-- /.col-lg-6 -->
                            <div class="col-lg-6">
                                <div class="input-group">
                                    <textarea id="sendtext" style="height: 100px" type="text" class="form-control" placeholder="Search for..."></textarea>
                                    <button onclick="send()" class="btn btn-default" type="button">发送</button>
                                </div><!-- /input-group -->
                            </div><!-- /.col-lg-6 -->
                        </div>
                        <script type="text/javascript">
                            function save(){
                                $.ajax({
                                    url:"/setting/save",
                                    data:{
                                        "port":$("#port").val(),
                                        "botelv":$("#botelv").val(),
                                        "jiaoyanwei":$("#jiaoyanwei").val(),
                                        "tingzhiwei":$("#tingzhiwei").val(),
                                        "type":$("#type").val()},
                                    success:function (data){
                                        if(data) {
                                            alert("保存成功")
                                        }
                                        else{
                                            alert("保存失败")
                                        }
                                    }
                                })
                            }
                            function OpenSerial(){
                                $.ajax({
                                    url:"/setting/OpenSerial",
                                    data:{
                                        "port":$("#port").val(),
                                        "botelv":$("#botelv").val(),
                                        "jiaoyanwei":$("#jiaoyanwei").val(),
                                        "tingzhiwei":$("#tingzhiwei").val(),
                                        "type":$("#type").val()},
                                    success:function (data){
                                        if(data=="开启成功"){
                                            window.location.reload()
                                        }
                                        else{
                                            alert(data)
                                        }
                                    }
                                })
                            }
                            function send(){
                                $.ajax({
                                    url:"/setting/send",
                                    data:{
                                        "data":$("#sendtext").val()}
                                })
                            }
                        </script>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
    <div style="height: 100px;"></div>
    <div class="form-actions" align="center">
        <input type="button" onclick="save()" class="btn btn-success " value="保存"> <a class="btn " href="javascript:history.back(-1)">返回</a>
    </div>
    <hr>

    <footer class="well">
        © Admin
    </footer>

</div>


</body>
</html>
